/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.PriorityQueue;
import java.io.IOException;

import org.graphstream.graph.Edge;
import org.graphstream.graph.Graph;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.DefaultGraph;
import org.graphstream.stream.file.FileSource;
import org.graphstream.stream.file.FileSourceFactory;
import org.graphstream.stream.file.FileSourceGML;
import org.graphstream.ui.swingViewer.Viewer;

import java.io.File;
import java.util.Collection;
/**
 *
 * @author joaovitor
 */
public class Grafos {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    	
    	Graph g = new DefaultGraph("g");
    	Graph gPrim = new DefaultGraph("gPrim");
    	String filePath = System.getProperty("user.dir")+"/arquivos/lesmis.gml";
        FileSource fs = null;
		try {
			fs = FileSourceFactory.sourceFor(filePath);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        fs.addSink(g);
        try {
			fs.readAll(filePath);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
   //     Viewer viewer = g.display();
     /*   Collection<Node> c = g.getNodeSet();
        Collection<Node> d = g.getNodeSet();
        if(c.equals(d))
        	System.out.println("ok");*/
        Prim p = new Prim();
        gPrim = p.runPrim(g);
        Viewer viewer = gPrim.display();
        //Viewer viewer = gPrim.display();
    /*    List<Edge> e = new ArrayList<Edge>();
        Edge aux = null;
        for(Edge ed : g.getEachEdge())
		{
        	e.add(ed);
		}
        Collections.sort(e, new WeightComparator());
        for(Edge ed : e)
        {
        	System.out.println(ed.getAttribute("value"));
        	aux = ed;
        }
        e.get(0).setAttribute("value", 25);
        Collections.sort(e, new WeightComparator());
        for(Edge ed : e)
        {
        	System.out.println("r"+ ed.getAttribute("value"));
        	aux = ed;
        }*/
    }
}

